package com.ymttest.business.data;

import org.junit.Test;

import com.shop2cn.iapi.member.parameter.CreateMemberBean;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.userservice.parameter.AddressRequestDtoBean;
import com.ymttest.business.service.AuthCallServiceV2;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.GodMemberService;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.utils.TestDataManager;

public class SqTestData {
	/**
	 * 创建账号并绑定会员手机号
	 * @throws Exception
	 */
	@Test
	public void Test1() throws Exception {
		int shopid = 500041475;
		TestDataManager.getData("1.txt").forEach(x -> {
			String mobile = x[0];
			UserCreateBean usercreateBean = DGUserCallService.initUsercreateBean();
			int userId;
			try {
				userId = DGUserCallService.UserCreateCall(usercreateBean);
				CreateMemberBean createMem = GodMemberService.initCreateMemberBean(shopid, userId,
						usercreateBean.getOpenId());
				createMem.setOpenId(usercreateBean.getOpenId());
				String memid = GodMemberService.creatememberCall(createMem);
				GodMemberService.bindMobile(shopid, userId, mobile);
				AddressRequestDtoBean addressBean = JUserCallService.initAddressBean(userId);
				String addressid = JUserCallService.AddressRequestDtoCall(addressBean);
				String token = AuthCallServiceV2.createToken(userId, "62");
				TestDataManager.appendFileToLine("testsquser.txt",
						userId + "," + token + "," + addressid + "," + mobile);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		});

	}
	/**
	 * 更新身份证
	 * @throws Exception
	 */
	@Test
	public void Test2() throws Exception {
		int shopid = 500041475;
		TestDataManager.getData("testsquser.txt",",").forEach(x -> {
			String userId = x[0];
			try {
				GodMemberService.UpdateIdCardNo(shopid, Integer.valueOf(userId));
			} catch (Exception e) {
				e.printStackTrace();
			}
		});

	}
}
